package january4;

/**
 * ClassName: 打印半金字塔，倒半金字塔，金字塔
 * Package: january4
 * Description:
 *
 * @Author fjorid
 * @Create 2025/1/4 20:28
 * @Version 1.0
 */
 class 金字塔 {
    public static void main(String[] args) {
        int n = 5;
        System.out.println("半金字塔");
        for (int i = 0; i < n; i++) {
            for (int j = 0; j <= i; j++) {
                System.out.print("*");
            }
            System.out.println("");
        }
        System.out.println("----------");
        System.out.println("倒半金字塔");
        for (int i = 0; i < n; i++) {
            for (int j = 5-i; j > 0; j--) {//金字塔行数加上此行要打印的*的个数为6
                System.out.print("*");
            }
            System.out.println("");
        }
        System.out.println("----------");
        System.out.println("全金字塔");
        for (int i = 0; i < n; i++) {
            for (int j = 0; j <= n - i; j++) {
                System.out.print(" ");//输出倒金字塔空行；
            }
            for (int k = 0; k <= i; k++) {//在对应的空行的基础上打印*，就是金字塔
                System.out.print("* ");
            }

            System.out.println("");
        }

    }
}